package com.hyts.reactive.publish;

import com.hyts.reactive.listener.item.BaseEventListener;
import com.hyts.reactive.module.BaseSubscription;
import com.hyts.reactive.module.Observable;
import com.hyts.reactive.module.Observer;
import com.hyts.reactive.module.Subscription;
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Scheduler;
import reactor.core.scheduler.Schedulers;

/**
 * project-name:coffice-toolbox
 * package-name:com.hyts.reactive.consume
 * author:Libo/Alex
 * create-date:2019-07-17 10:52
 * email:liboware@gmail.com
 * description: simple and base publisher server bus
 */
public class BasePublisher implements Observable<Object>{

    /**
     * publish event object
     * @param param
     * @param scheduler
     * @return
     */
    @Override
    public Subscription publish(Object param, Scheduler scheduler) {
        return new BaseSubscription(Flux.just(param).subscribeOn(scheduler));
    }

    /**
     * publish event object
     * @param scheduler
     * @param param
     * @return
     */
    @Override
    public Subscription publish(Scheduler scheduler, Object... param) {
        return new BaseSubscription(Flux.just(param).subscribeOn(scheduler));
    }
    /**
     * publish the event object
     * @param param
     * @return
     */
    @Override
    public Subscription publish(Object param) {
        return new BaseSubscription(Flux.just(param).subscribeOn(Schedulers.elastic()));
    }
    /**
     * publish the sequence event object
     *@param param
     * @return
     */
    @Override
    public Subscription publish(Object... param) {
        return new BaseSubscription(Flux.just(param).subscribeOn(Schedulers.elastic()));
    }
}
